<template>
  <div>这里是home-固定路由</div>
  <!-- <router-link to="/user/good">去动态路由 good</router-link>
  <router-link to="/user/contact">去动态路由 contact</router-link> -->
  <button @click="go('/user/good')">去动态路由 good</button>
  <button @click="go('/user/contact')">去动态路由 contact</button>
  <button @click="logOut">退出登录</button>
</template>
<script>
import { useRouter } from "vue-router";
import { useStore } from "vuex";
export default {
  setup() {
    const router = useRouter();
    const store = useStore();
    function go(path) {
      router.push({
        path,
      });
    }
    function logOut() {
      store.dispatch("logOut").then(() => {
        window.localStorage.removeItem("token");
        router.push({
          path: "/login",
        });
      });
    }
    return {
      go,
      logOut,
    };
  },
};
</script>